<?php

abstract class ACoreBaseContainer
{
	#<editor-fold defaultstate="collapsed" desc="protected">
	/**
	 * @var	array
	 */
	protected $aContainer;
	#</editor-fold>

	/**
	 * @return	ACoreBaseContainer
	 */
	public function __construct()
	{
		$this->aContainer = array();
	}

	/**
	 * @param	string	$sKey
	 * @param	string	$nsType = null
	 * @return	mixed
	 */
	public function GetValue($sKey, $nsType = null)
	{
		CCore::CheckTypes(array('$sKey', '$nsType'));
		
		$bReturn = null;
		if (array_key_exists($sKey, $this->aContainer))
		{
			$bReturn = $this->aContainer[$sKey];
			if (null !== $nsType)
			{
				settype($bReturn, $nsType);
			}
		}
		return $bReturn;
	}

	/**
	 * @param	string	$sKey
	 * @param	mixed	$mValue
	 * @param	string	$sType = null
	 * @return	bool
	 */
	public function SetValue($sKey, $mValue, $nsType = null)
	{
		CCore::CheckTypes(array('$sKey', '$mValue', '$nsType'));
				
		if (array_key_exists($sKey, $this->aContainer))
		{
			if (null !== $nsType)
			{
				settype($mValue, $nsType);
			}
			$this->aContainer[$sKey] = $mValue;
			return true;
		}
		return false;
	}

	/**
	 * @param	array	$aValues
	 * @return	bool
	 *
	 */
	public function MassSetValues($aValues)
	{
		CCore::CheckTypes(array('$aValues'));
		
		$bReturn = true;
		foreach ($aValues as $sKey => $mValue)
		{
			$bReturn &= $this->SetValue($sKey, $mValue);
		}
		return $bReturn;
	}
}